import router from '@/router';
import { ElMessage, ElMessageBox } from 'element-plus'

export const navigationTo = (path: string) => {
  router.push(path)
}

export const Message = (message: any, type: any):void => {
  ElMessage({ message, type, plain: true });
}

export const elMessageBox = (name: string, delete_time: number, callback: ((arg0: boolean) => void) | any) => {
  let tip, title = '';
  if(delete_time){
    tip =`您确定要恢复 ${name} 的数据吗？`;
    title = '恢复提示';
  } else {
    tip =`您确定要删除 ${name} 的数据吗？`;
    title = '删除提示';
  }
    

  let verifyVla = false;
  ElMessageBox.confirm( tip, title,
    {
      confirmButtonText: '确定',
      cancelButtonText: '关闭',
      type: 'warning',
    }
  ).then(() => {
    verifyVla = true;
    callback(verifyVla);
  }).catch(() => {
    ElMessage({ type: 'info', message: '取消操作' });
    callback(verifyVla);
  })
}